/*
 ConfirmationViewController.m
 
 The view controller class that handles the confirmation windows that
 appear when the "new" or "save" buttons are pressed.
 
 Created by David Kikuta.
 */

#import "ConfirmationViewController.h"


@implementation ConfirmationViewController

@synthesize delegate, messageType;

- (void)completeAction {
	switch(messageType) {
		case 0:
			[self.delegate saveImage];
			break;
		case 1:
			[self.delegate clearCanvas];
			break;
		default:
			break;
	}
}

- (void)confirmButtonPressed:(UIButton *) sender {
	[self completeAction];
}

- (IBAction)denyButtonPressed:(UIButton *) sender {
	[self.delegate closeConfirmationWindow];
}

- (void)setMessage:(int)type {
	messageType = type;
	NSString * text;
	switch(type) {
		case 0:
			text = @"Are you sure you want to save?";
			[confirmationMessage setText:text];
			break;
		case 1:
			text = @"Are you sure you want to clear the canvas?";
			[confirmationMessage setText:text];
			break;
		default:
			break;
	}
}

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
    // Overriden to allow any orientation.
    return YES;
}


- (void)didReceiveMemoryWarning {
    // Releases the view if it doesn't have a superview.
    [super didReceiveMemoryWarning];
}


- (void)viewDidUnload {
    [super viewDidUnload];
    // Release any retained subviews of the main view.
    // e.g. self.myOutlet = nil;
}


- (void)dealloc {
    [super dealloc];
}


@end
